1204A - BowWow and the Timetable - CodeForces Solution


math *1000

Please click on ads to support us..

Python Code:

s=input()
t=0
l=0
for i in range(len(s)-1,-1,-1):
    t+=int(s[i])*(2**l)
    l+=1
k=1
c=0
while(k<t):
    c+=1
    k*=4
print(c)

C++ Code:

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <deque>
#include <cassert>
#include <iomanip>
#include <chrono>
using namespace std ;
#define ll long long

void FastInputOutput(){
    ios_base::sync_with_stdio( 0 );
    cin.tie(0);
    cout.tie(0);
}

inline int D(){
    int t;
    scanf("%d", &t);
    return t;
}
inline ll LLD(){
    ll t;
    scanf("%lld", &t);
    return t;
}
ll gcd(ll a, ll b){
    return b ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b){
    // gcd * lcm = a * b --> lcm = a / gcd * b;
    return a / gcd(a, b) * b;
}

long double ModLog(long double base, long double x) {
    return (logl(x) / logl(base));
}

int addmod(int a, int b, int m){
    return (((a % m) + (b % m) + m) % m);
}

const int N = 2e5 + 5, mod = 1e9 + 7;
char a[N];
void solve(){
    scanf("%s", a);
    int ans = (strlen(a) + 1) / 2;
    bool arrived = true;
    for(int i = 1; a[i]; ++i)
        arrived &= a[i] == '0';
    ans -= arrived && (strlen(a) & 1);
    printf("%d", ans);
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("//Users//amrsaud//Desktop//PS//in1", "r", stdin);
    //freopen("////Users//amrsaud//Desktop//PS//in1", "w", stdout);
#else
    // online submission
#endif
//    int t = D();
    int t = 1;
    while (t--) {
        solve();
    }
    return 0;
}


Comments

Submit
0 Comments
More Questions

1566B - MIN-MEX Cut
678C - Joty and Chocolate
1352E - Special Elements
1520E - Arranging The Sheep
1157E - Minimum Array
1661D - Progressions Covering
262A - Roma and Lucky Numbers
1634B - Fortune Telling
1358A - Park Lighting
253C - Text Editor
365B - The Fibonacci Segment
75A - Life Without Zeros
1519A - Red and Blue Beans
466A - Cheap Travel
659E - New Reform
1385B - Restore the Permutation by Merger
706A - Beru-taxi
686A - Free Ice Cream
1358D - The Best Vacation
1620B - Triangles on a Rectangle
999C - Alphabetic Removals
1634C - OKEA
1368C - Even Picture
1505F - Math
1473A - Replacing Elements
959A - Mahmoud and Ehab and the even-odd game
78B - Easter Eggs
1455B - Jumps
1225C - p-binary
1525D - Armchairs